package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteModelService;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.system.api.model.ModelRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteModelFallbackFactory implements FallbackFactory<RemoteModelService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteModelFallbackFactory.class);

    @Override
    public RemoteModelService create(Throwable throwable)
    {
        log.error("模型接口服务调用失败:{}", throwable.getMessage());
        return new RemoteModelService()
        {


            @Override
            public R<List<Map<String, Object>>> getNERResult(ModelRequest modelRequest, String source) {
                return R.fail("调用实体要素抽取模型失败:" + throwable.getMessage());
            }

            @Override
            public R<List<Map<String, Object>>> getREResult(ModelRequest modelRequest, String source) {
                return R.fail("调用关系要素抽取模型失败:" + throwable.getMessage());
            }

            @Override
            public R<List<Map<String, Object>>> getEEResult(ModelRequest modelRequest, String source) {
                return R.fail("调用事件要素抽取模型失败:" + throwable.getMessage());
            }
        };
    }
}
